<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="import" uri="/WEB-INF/tld/importTag.tld" %>
    <%@taglib prefix="mu" uri="/WEB-INF/tld/mallutil.tld" %>
<%@taglib prefix="pu" uri="/WEB-INF/tld/pageutil.tld" %>
<%@taglib prefix="pageable" uri="/WEB-INF/tld/pageable.tld" %>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>

<import:around enableCache="false" url="/qaa/cs?memberId=${mu:memberId()}" appendParameter="memberId,answered">
<script>
$(function(){

	
	if('${param.answered}'=='true'){
		$('#current_location').html(' > 客服问答 - 已回答');
		$("#m_cs_answered").css("font-weight","bold");
	}else{
		if('${!empty param.orderId}'=='true'){
			$('#current_location').html(' > 客服问答');
			
		}else{
			$('#current_location').html(' > 客服问答 - 发问中');
			$("#m_cs_asked").css("font-weight","bold");
		}
	}
});
</script>
${pu:reqSet('tp', pu:pageableTag('key', 10, 10))}

<c-rt:choose>
<c-rt:when test="${!empty param.orderId}">

<c-rt:set var="aHql">
from Question q where q.extraValue['orderId'].value=? order by createDate desc
</c-rt:set>
${pu:listAdd('params', param.orderId) }
${pu:reqSet('questions', pu:queryByHql(aHql, pu:arrayGet('params'), tp)) }

</c-rt:when>
<c-rt:otherwise>


<c-rt:if test="${empty param.answered || param.answered=='false'}">
<c-rt:set var="aHql">
from Question q where q.memberId=? and q.answer=null and q.extraValue['isProductQAA'].value=? order by createDate desc
</c-rt:set>
${pu:listAdd('params', mu:memberId()) }
${pu:listAdd('params', 'false') }
${pu:reqSet('questions', pu:queryByHql(aHql, pu:arrayGet('params'), tp)) }
</c-rt:if>
<c-rt:if test="${!empty param.answered && param.answered=='true'}">
<c-rt:set var="aHql">
from Question q where q.memberId=? and q.answer!=null and q.extraValue['isProductQAA'].value=? order by createDate desc
</c-rt:set>
${pu:listAdd('params', mu:memberId()) }
${pu:listAdd('params', 'false') }
${pu:reqSet('questions', pu:queryByHql(aHql, pu:arrayGet('params'), tp)) }
</c-rt:if>
</c-rt:otherwise>
</c-rt:choose>




<c-rt:if test="${empty questions}">
<!-- content start --> 
  <div class="content mb-od"> 
    <!-- 问答记录 --> 
    <h2>客服问答</h2> 
    <div class="service-ask-no"> 
    <div class="servicemsg2">您好!<br /> 
      目前您尚无任何问答记录,请点选 <a href="<c-rt:url value="/member/cs/page.do?page=request"/>"><span class="txt-s">我要询问</span></a>！</div>	
</div> 
    </div> 

  <!-- content end --> 
</c-rt:if>
<c-rt:if test="${!empty questions}">
<!-- content start --> 
  <div class="content mb-od"> 
    <!-- 问答记录 --> 
    <h2>客服问答</h2> 
    <table class="tb-2-ser"> 
        <tr> 
          <th width="15%">问题编号</th> 
          <th width="20%">提问日期</th> 
          <th width="20%">提问来源</th> 
          <th width="20%">商品名称</th> 
          <th width="15%">提问类别</th> 
          <th width="10%">问题查询</th> 
        </tr> 
        
        <c-rt:forEach items="${questions }" var="question">
        <tr> 
          <td>${question.id }</td> 
          <td><fmt-rt:formatDate value="${question.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td> 
          <td>
          	<c-rt:if test="${!empty question.extraValue['orderId'].value}">
          	订单:<a href="<c-rt:url value="/member/order/page.do?page=detail&orderId=${question.extraValue['orderId'].value }"/>">${question.extraValue['orderId'].value }</a>
          	</c-rt:if>
          	</td> 
          <td>
			<c-rt:if test="${!empty question.extraValue['productId'].value}">
				<c-rt:set var="product" value="${pu:get('com.yaodian100.ec.product.entity.Product', question.extraValue['productId'].value)}"/>
				<a href="<c-rt:url value="/product/product.do?productId=${question.extraValue['productId'].value }"/>">${product.productName }</a>
			</c-rt:if>
		  </td> 
          <td>
			<c-rt:if test="${!empty question.extraValue['class2'].value}">
				<c-rt:set var="cqt" value="${pu:get('com.yaodian100.crm.cs.entity.CommonQuestionType', question.extraValue['class2'].value)}"/>
				${cqt.name }
			</c-rt:if>
		  </td> 
          <td><a href="<c-rt:url value="/member/cs/page.do?page=request&questionId=${question.id }&orderId=${question.extraValue['orderId'].value }&productId=${question.extraValue['productId'].value }"/>">询问</a>&nbsp;<a href="<c-rt:url value="/member/cs/page.do?page=record&questionId=${question.id }"/>">记录</a></td> 
        </tr> 
        </c-rt:forEach>
        
      </table> 
       <div class="page-accound1"></div>
       <c-rt:if test="${param.answered=='true'}">
       <c-rt:set var="csQaaUrl">
       <c-rt:url value="/member/cs/qaa.do?answered=true"/>
       </c-rt:set>
       </c-rt:if>
       <c-rt:if test="${param.answered=='false'}">
       <c-rt:set var="csQaaUrl">
		<c-rt:url value="/member/cs/qaa.do?answered=false"/>
	   </c-rt:set>
       </c-rt:if> 
          <p class="page-change"><a href="#" class="f-rt"><span class="a-top"></span>Top</a>第${tp.currentPage }页，共${tp.totalPages}页<pageable:Pageable formname="pageableForm" url="${csQaaUrl}" key="key"/></p> 
      <p align="center"><a class="btn-mid" href="<c-rt:url value="/member/cs/page.do?page=request"/>">我要询问</a></p> 
      
     
    </div> 
  <!-- content end --> 
</c-rt:if>
</import:around>